import 'package:flutter/material.dart';
import 'package:flutter_common/ui/widget/click.dart';
import 'package:flutter_common/ui/widget/text.dart';
import 'package:flutter_common/util/toast_util.dart';

class ClickDemo extends StatelessWidget {

  ClickDemo({super.key});

  @override
  Widget build(BuildContext context) {
    final list = body();
    return Scaffold(
      appBar: AppBar(title: const Text("click demo")),
      body: SingleChildScrollView(
        child: Column(
          children: list,
        ),
      ),
    );
  }

  List<Widget> body() {
    return [
      FxClick(
        child: const Padding(
          padding: EdgeInsets.symmetric(vertical: 8, horizontal: 15),
          child: Text("click"),
        ),
      ),
      FxClick(
        child: const Padding(
          padding: EdgeInsets.symmetric(vertical: 8, horizontal: 15),
          child: Text("click press"),
        ),
        onTap: ()=>ToastUtil.showToast("click press"),
      ),
      FxClick(
        child: const Padding(
          padding: EdgeInsets.symmetric(vertical: 8, horizontal: 15),
          child: Text("click long press"),
        ),
        onTap: ()=>ToastUtil.showToast("click press"),
        onLongPress: ()=>ToastUtil.showToast("click long press"),
      ),
      FxClick(
        color: Colors.amber,
        child: const Padding(
          padding: EdgeInsets.symmetric(vertical: 8, horizontal: 15),
          child: Text("click color"),
        ),
        onTap: ()=>ToastUtil.showToast("click color press"),
        onLongPress: ()=>ToastUtil.showToast("click color long press"),
      ),
      FxClick(
        color: Colors.green,
        borderRadius: BorderRadius.circular(10),
        child: const Padding(
          padding: EdgeInsets.symmetric(vertical: 8, horizontal: 15),
          child: Text("click radius color,wait tap"),
        ),
        onTap: ()async{
          ToastUtil.showToast("click press");
          await Future.delayed(const Duration(seconds: 10));
        },
        onLongPress: ()async{
          ToastUtil.showToast("click long press");
          await Future.delayed(const Duration(seconds: 15));
        },
      ),
      FxClick(
        color: Colors.red,
        debounce: false,
        borderRadius: BorderRadius.circular(10),
        child: const Padding(
          padding: EdgeInsets.symmetric(vertical: 8, horizontal: 15),
          child: Text("click radius color debounce"),
        ),
        onTap: ()=>ToastUtil.showToast("click press"),
        onLongPress: ()=>ToastUtil.showToast("click long press"),
      ),
      FxClick(
        color: Colors.blueAccent,
        asyncTap: false,
        borderRadius: BorderRadius.circular(10),
        child: const Padding(
          padding: EdgeInsets.symmetric(vertical: 8, horizontal: 15),
          child: Text("click radius color asyncTap"),
        ),
        onTap:  ()async{
          ToastUtil.showToast("click press");
          await Future.delayed(const Duration(seconds: 10));
        },
        onLongPress:  ()async{
          ToastUtil.showToast("click long press");
          await Future.delayed(const Duration(seconds: 10));
        },
      ),
      FxClick(
        //背景样式
        decoration:  BoxDecoration(
          borderRadius: BorderRadius.circular(10),
          border: Border.all(color: Colors.indigoAccent,width: 3),
          color: Colors.red,
        ),
        //只对点击后的有圆角
        borderRadius: BorderRadius.circular(10),
        child:  Container(
          padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 15),
          child: const Text("click radius decoration"),
        ),
        onTap: ()=>ToastUtil.showToast("click press"),
        onLongPress: ()=>ToastUtil.showToast("click long press"),
      ),
      FxCheckBox(value: true, onChanged: (bool? value) {}, text: 'sssg'),
      FxCheckBox(value: true, text: 'sssgxx'),
    ];
  }
}
